#include <stdio.h>
#include <math.h>

// 函数声明
int count_special(int n);

int main(void)
{
    int n;
    scanf("%d", &n);
    printf("%d\n", count_special(n));
    return 0;
}

// 判断是否有两位数字相同
int has_two_same_digit(int num)
{
    int a = num / 100;
    int b = (num / 10) % 10;
    int c = num % 10;
    return (a == b) || (a == c) || (b == c);
}

// 统计满足条件的三位数
int count_special(int n)
{
    int count = 0;
    for (int i = 101; i <= n; i++) {
        int root = (int)sqrt(i);
        if (root * root == i && has_two_same_digit(i))
            count++;
    }
    return count;
}